package com.harry.resource.inner.properties;

import java.util.Map;

import org.apache.commons.lang3.ArrayUtils;

import com.harry.basis.PropertySettings;
import com.harry.configuration.ConstSettings;
import com.harry.resource.inner.entity.InnerPerm;
import com.harry.utility.InnerUtils;
import com.harry.utility.query.InnerCriterion;

public class Ps4InnerPerm extends PropertySettings<InnerPerm> {

	@Override
	public String[] nameProperties() {
		return new String[] { "name" };
	}

	@Override
	public String[] keyProperties() {
		return new String[] { "name", "route" };
	}

	@Override
	public String[] listProperties() {
		return new String[] { "name", "route", "roles.name" };
	}

	@Override
	public String[] editProperties() {
		return allFields();
	}

	@Override
	public String[] addProperties() {
		return allFields();
	}

	@Override
	public String[] criteriaProperties() {
		return new String[] { "roles" };
	}

	@Override
	public String[] listLabels() {
		return null;
	}

	@Override
	public Integer[] listIndexes() {
		return null;
	}

	@Override
	public String[] editLabels() {
		return null;
	}

	@Override
	public Integer[] editIndexes() {
		return null;
	}

	@Override
	public String[] addLabels() {
		return null;
	}

	@Override
	public Integer[] addIndexes() {
		return null;
	}

	@Override
	public String[] criteriaLabels() {
		return null;
	}

	@Override
	public Integer[] criteriaIndexes() {
		return null;
	}

	@Override
	public void adminSettings(Map<String, Map<String, Object>> admin_map) {
		super.adminSettings(admin_map);
		admin_map.put("getlist", InnerUtils.mapObject());
	}

	@Override
	public void permSettings(Map<String, Map<String, Object>> perm_map) {
		super.permSettings(perm_map);
		perm_map.put("getlist", InnerUtils.mapObject("criteria.criterions[?]", new InnerCriterion("or", ArrayUtils.toArray(// e
				new InnerCriterion("eq", "roles.users.id", "{{user.id}}"), // e
				new InnerCriterion("eq", "roles.name", ConstSettings.NAME_OF_DEFAULT_ROLE)// e
		))));
	}
}
